<!-- 详情 -->
<template>
	<div>
		<el-form :model="editForm" ref="editForm" >
			<el-row>
				<el-col :span="12">
					<el-form-item label="模型名称" prop="training_name">
						<el-input v-model="editForm.training_name" readonly placeholder="请输入策略名称" size="large"></el-input>
					</el-form-item>
				</el-col>
				<el-col :span="12">
					<el-form-item label="状态" prop="state">
						<el-input v-if="editForm.state == 1" size="large" value='训练中' readonly></el-input>
						<el-input v-if="editForm.state == 2" size="large" value='已完成' readonly></el-input>
					</el-form-item>
				</el-col>
				<el-col :span="12">
					<el-form-item label="Benchmark" >
						<el-input v-model="editForm.all_result.benchmark" readonly placeholder="交易笔数" size="large"></el-input>
					</el-form-item>
				</el-col>
				<el-col :span="12">
					<el-form-item label="PL" prop="total_pl">
						<el-input v-model="editForm.all_result.total_pl" readonly placeholder="总收益" size="large"></el-input>
					</el-form-item>
				</el-col>
				<el-col :span="12">
					<el-form-item label="Accuracy" prop="accuracy">
						<el-input v-model="editForm.all_result.accuracy" readonly placeholder="总收益" size="large"></el-input>
					</el-form-item>
				</el-col>
				<el-col :span="12">
					<el-form-item label="Test_PL" prop="total_pl">
						<el-input v-model="editForm.test_result.total_pl" readonly placeholder="手续费" size="large"></el-input>
					</el-form-item>
				</el-col>
				<el-col :span="12">
					<el-form-item label="Test_Accuracy" prop="avg_winning_trade">
						<el-input v-model="editForm.test_result.accuracy" readonly placeholder="平均盈利" size="large"></el-input>
					</el-form-item>
				</el-col>
				<el-col :span="12">
					<el-form-item label="备注" prop="comment">
						<el-input v-model="editForm.comment" readonly placeholder="备注" size="large"></el-input>
					</el-form-item>
				</el-col>
				<el-col :span="12" v-for="(item,index) in editForm.images" :key="index">
					<el-form-item :label="item.name">
						<el-image style="width: 100%;" :src="item.url" :preview-src-list="[item.url]"> </el-image>
					</el-form-item>
				</el-col>
			</el-row>
		</el-form>
	</div>
</template>

<script>
import {addStrategyAPI,editStrategyAPI,} from '@/api/index';

export default {
	name: 'editModel',
	props: {
		Infoitem: Object
	},
	data() {
	    return {
			title:'',
			editForm:{}
	    };
	},
	mounted() {
		console.log(this.Infoitem)
		this.editForm = this.Infoitem
	},
	methods:{
		saveEdit(){
			var that = this
			that.$refs.editForm.validate(valid => {
			    if (valid) {
					if(that.editForm.model_id){
						editStrategyAPI(that.editForm).then(res => {
							if(res.status == 200){
								that.$message.success(`修改成功`);
								that.closedialog();
							}else{
								that.$message.error(res.msg);
							}
						});
					}else{
						addStrategyAPI(that.editForm).then(res => {
							if(res.status == 200){
								that.$message.success(`添加成功`);
								that.closedialog();
							}else{
								that.$message.error(res.msg);
							}
						});
					}
			    } else {
			        console.log('error submit!!');
			        return false;
			    }
			});
		},
		closedialog() {
			this.$emit('closeDialog', false);
		}
	}
};
</script>

<style scoped>
.dialog-footer {
	width: 100%;
	text-align: right;
}
/deep/.el-col-12{
	padding: 0 15px;
}
</style>
